<template>
  <div class="active-user-card">
    <div class="title">当前活跃用户数</div>
    <div class="count">{{ count }}</div>
  </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
import { getActievUsers } from "@/api/screen";

const count = ref(0);

const fetchData = async () => {
  const res = await getActievUsers();
  if (res.code === 0) {
    count.value = res.data.activeUsers;
  }
};

onMounted(() => {
  fetchData();
  // setInterval(fetchData, 5000); // 每 5 秒更新一次
});
</script>

<style scoped>
.active-user-card {
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, #0f2027, #203a43, #2c5364);
  color: #00e8ff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
  font-family: "Arial", sans-serif;
  box-shadow: 0 0 12px rgba(0, 232, 255, 0.3);
}

.title {
  font-size: 16px;
  margin-bottom: 8px;
}

.count {
  font-size: 32px;
  font-weight: bold;
}
</style>
